﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.IO;
namespace DataSyn.MDL
{
    class Config
    {
        Configuration cfg = null;
        BaseLibrary.ClassLibrary.ConfigSetting configSetting;
        public Config()
        {
            configSetting = new BaseLibrary.ClassLibrary.ConfigSetting(cfg = BaseLibrary.ClassLibrary.ConfigSetting.OpenConfig(Path.Combine(System.Windows.Forms.Application.StartupPath,"config.config")));
        }
        public string DataConnectionString
        {
            get
            {
                return configSetting.GetSetting("DataConnectionString");
            }
            set
            {
                configSetting.SetSetting("DataConnectionString", value);
            }
        }
        public BaseLibrary.CDataContext.EProvider Provider
        {
            get
            {
                return BaseLibrary.ClassLibrary.Enum.GetValue<BaseLibrary.CDataContext.EProvider>(configSetting.GetSetting("Provider"));
            }
            set
            {
                configSetting.SetSetting("Provider", BaseLibrary.ClassLibrary.Enum.GetName(value));
            }
        }
        public void Save()
        {
            configSetting.Save();
        }
    }
}
